package com.example.demo.Controller;

import com.example.demo.bean.staff;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;
@RestController
@Api(tags="员工管理")

@RequestMapping("/staff")
public class staffController {
    @Autowired
    private com.example.demo.service.staffService staffService;

    /**
     * 添加信息
     * @param@RequestParam("staffid") int staffid,@RequestParam("staffname") String staffname,@RequestParam("staffgender") String staffgender,@RequestParam("staffprofession") String staffprofession,@RequestParam("staffyear") int staffyear,@RequestParam("staffphoto") String staffphoto
     * @returnstaffid,staffname,staffgender,staffprofession,staffyear,staffphoto
     */
    @PostMapping("/Insertstaff")
    @ApiOperation(value = "增加员工信息", notes = "插入员工信息")
    public int Insertstaff(staff staff){
        return staffService.Insertstaff(staff);
    }

    /**
     * 通过商品编号删除数据
     * @param
     * @return
     */
    @PostMapping("/Deletestaff")
    @ApiOperation(value = "删除员工信息", notes = "根据员工Id信息")

    @ResponseBody
    public int Deletestaff(@RequestParam("staffid") Integer staffid){
        return staffService.Deletestaff(staffid);
    }

    /**
     * 修改信息
     * @param
     * @return
     */
    @PostMapping("/Updatestaff")
    @ApiOperation(value = "更新员工信息", notes = "根据员工Id修改信息")
    @ResponseBody
    public int Updatestaff( staff staff ) {
        return staffService.Updatestaff(staff);
    }

    /**
     * 显示所有数据
     * @return
     */
    @PostMapping("/ShowAllstaff")
    @ApiOperation(value = "获取员工信息列表", notes = "获取所有员工信息")
    @ResponseBody
    public List<staff> ShowAllstaff() {
        return staffService.ShowAllstaff();
    }



    /**
     * 查询商品总数
     * @return
     */
    @PostMapping("/Totalstaff")
    @ApiIgnore
    @ResponseBody
    public int Totalstaff(){
        return staffService.Totalstaff();
    }
}
